#导入jwt
import jwt

#封装一个类
class Myjwt():
    def __init__(self):
        self.SECRET_KEY='zvjfdnvjdvndfkbv'

    #生成token
    def jwt_encode(self,data):
        token=jwt.encode(data,self.SECRET_KEY,algorithm='HS256')
        return token

    #解析token
    def jwt_decode(self,token):
        try:
            payload=jwt.decode(token,self.SECRET_KEY,algorithms='HS256')
            return payload
        except:
            return None

myjwt=Myjwt()
